import pytest

import page
from page.page_in import PageIn
from tools.get_driver import GetDriver
from tools.get_log import GetLog
from tools.read_yaml import read_yaml

log = GetLog.get_logger()

class TestAxaLogin:
    # 初始化
    def setup_class(self):
        driver = GetDriver.get_web_driver(page.axa_sit_login_url)
        self.login = PageIn(driver).page_get_PageAxaLogin()

    # 结束
    def teardown_class(self):
        GetDriver.quit_web_driver()

    # 登陆业务 测试
    @pytest.mark.parametrize("axa_memberName,axa_password,axa_code,expect", read_yaml('axa_login.yaml'))
    def test_axa_login(self, axa_memberName, axa_password, axa_code, expect):
        self.login.page_axa_login(axa_memberName, axa_password, axa_code)
        print('登陆的用户为 ：', self.login.base_get_text(page.axa_username))
        try:
            assert expect in self.login.base_get_text(page.axa_username)
        except Exception as e:
            log.error('断言错误问题：{}'.format(e))
            # 截图
            self.login.base_get_image()
            raise
